/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cardgame.game.events;

import cardgame.game.*;


/**
 *
 * @author Carl
 */
public class PayCostsEvent extends Event{

    public PayCostsEvent(Player player, Cost cost, Card card, int[] manaIndices){
        this.player = player;
        this.cost = cost;
        this.card = card;
        this.manaIndices = manaIndices;
    }
    protected Player player;
    protected Cost cost;
    protected Card card;
    protected int[] manaIndices;

    @Override
    public void trigger(Game game){
        if(cost.isTap()){
            game.triggerEvent(new TapEvent(card));
        }
        for(int manaIndex : manaIndices){
            ManaProvider manaProvider = (ManaProvider) player.getManaPool().get(manaIndex);
            player.getManaPool().provide(manaProvider);
        }
        game.triggerEvent(new AddPlayerLifepointsEvent(player, -1 * cost.getLifepoints()));
    }

    public Player getPlayer(){
        return player;
    }

    public Cost getCost(){
        return cost;
    }

    public Card getCard(){
        return card;
    }

    public int[] getManaIndices(){
        return manaIndices;
    }
}
